﻿using FriendlyURL.Web.Domain.Abstract;

namespace FriendlyURL.Web.Domain.Impl
{
    public class UserCookie : IUserCookie
    {
        private IMessageHandler messageHandler;

        public UserCookie()
        {
            this.messageHandler = DIFactory.CreateMessageHandlerType();
        }

        //public string ReadShippingDetailsFromCookie()
        //{
        //    string shippingDetails = string.Empty;

        //    try
        //    {
        //        if (HttpContext.Current.Request.Cookies[GlobalProperties.APPLICATION_COOKIE_NAME] != null)
        //        {
        //            shippingDetails = HttpContext.Current.Request.Cookies[GlobalProperties.APPLICATION_COOKIE_NAME][GlobalProperties.APPLICATION_COOKIE_SHIPPING_DETAILS];
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        messageHandler.HandleError(ex);
        //    }

        //    return shippingDetails;
        //}

        //public void WriteShippingDetailsToCookie(string shippingDetails)
        //{
        //    try
        //    {
        //        HttpCookie cookie = new HttpCookie(GlobalProperties.APPLICATION_COOKIE_NAME);
        //        cookie[GlobalProperties.APPLICATION_COOKIE_SHIPPING_DETAILS] = shippingDetails;
        //        cookie.Expires = DateTime.Now.AddDays(1);

        //        HttpContext.Current.Response.Cookies.Add(cookie);
        //    }
        //    catch (Exception ex)
        //    {
        //        Log.Write("Exception Occured: " + ex.Message);
        //        messageHandler.HandleMessage("Error occured while trying to save a user's shipping details.", GlobalProperties.LogWarningName, true);
        //    }
        //}
    }
}
